<template>
	<view class="container">
		<view class="content">
			hha
			<!-- 左侧分类栏 -->
			<!-- <scroll-view class="menus" :scroll-into-view="menuScrollIntoView" scroll-with-animation scroll-y>
				<view class="wrapper">
					<view class="menu" :id="`menu-${item.id}`" :class="{'current': item.id === currentCateId}" v-for="(item, index) in goods" 
					:key="index" @tap="handleMenuTap(item.id)">
						<text>{{ item.name }}</text>
						<view class="dot" v-show="menuCartNum(item.id)">{{ menuCartNum(item.id) }}</view>
					</view>
				</view>
			</scroll-view> -->
			
		</view>
	</view>
</template>

<script>
	import api from '@/api/index.js'
export default {
	data() {
		return {
			menuScrollIntoView: '',		
			goods: [], //所有商品
			currentCateId: 6905,//默认分类
			cart: [], //购物车
		}
	},
	computed:{
		menuCartNum() {
			return (id) => this.cart.reduce((acc, cur) => {
					if(cur.cate_id === id) {
						return acc += cur.number
					}
					return acc
			}, 0)
		},
	},
	async onLoad() {
		// await this.init()
		console.log("menu---")
	},
	
	async created() {
		console.log("menu---created")
		this.goods = await api("goods")
		console.log("this.goods = ", this.goods)
	},
	
	mounted() {
		console.log("menu---mounted")
	},
	
	destroyed() {
		console.log("menu---destroyed")
	}
}
</script>

<style lang="scss" scoped>
	@import '~@/pages/newHome/menu/menu.scss';
</style>
